package com.ebook.ui.fragment.home.littlebookcase;

import com.ebook.entity.Book;
import com.ebook.entity.BookReadData;
import com.ebook.entity.User;
import com.ebook.ui.fragment.Fragment;
import com.ebook.ui.fragment.home.everyrecommend.ImgContainer;
import com.ebook.ui.sync.WorkSyncer;

import javax.swing.*;
import java.awt.*;

public class RecentBook extends Fragment {
    private BookReadData bookReadData;
    public RecentBook(BookReadData bookReadData){
        super();
        this.bookReadData = bookReadData;
        initComponents();
        setBackground(Color.ORANGE);
    }
    @Override
    public void initComponents(){
        Book book = WorkSyncer.bookService.selectBookById(bookReadData.getBookId());
        System.out.println(book);
        ImgContainer img = new ImgContainer(book.getImage(),new User());
        JLabel bookName = new JLabel(book.getBook_name(),SwingConstants.CENTER);
        System.out.println("书名"+book.getBook_name());
        JLabel progress = new JLabel("读到"+bookReadData.getCategory()+"章");
        img.setBounds(6,10,36,36);
        bookName.setBounds(56,10,64,30);
        progress.setBounds(56,50,64,30);
        add(img);
        add(bookName);
        add(progress);
    }
}
